EC-CUBE 2.4.4
[ class tree: EC-CUBE 2.4.4 ] [ index: EC-CUBE 2.4.4 ] [ all elements ]

Source for file SC_Initial.php

Documentation is available at SC_Initial.php

  1. <?php
  2. /*
  3.  * This file is part of EC-CUBE
  4.  *
  5.  * Copyright(c) 2000-2010 LOCKON CO.,LTD. All Rights Reserved.
  6.  *
  7.  * http://www.lockon.co.jp/
  8.  *
  9.  * This program is free software; you can redistribute it and/or
  10.  * modify it under the terms of the GNU General Public License
  11.  * as published by the Free Software Foundation; either version 2
  12.  * of the License, or (at your option) any later version.
  13.  *
  14.  * This program is distributed in the hope that it will be useful,
  15.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  17.  * GNU General Public License for more details.
  18.  *
  19.  * You should have received a copy of the GNU General Public License
  20.  * along with this program; if not, write to the Free Software
  21.  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  22.  */
  23.  
  24. /**
  25.  * アプリケーションの初期設定クラス.
  26.  *
  27.  * @author LOCKON CO.,LTD.
  28.  * @version $Id: SC_Initial.php 18747 2010-06-23 04:42:53Z kajiwara $
  29.  */
  30. class SC_Initial {
  31.  
  32.     // {{{ cunstructor
  33.  
  34.     /**
  35.      * コンストラクタ.
  36.      */
  37.     function SC_Initial({
  38.  
  39.         /** EC-CUBEのバージョン */
  40.         define('ECCUBE_VERSION'"2.4.4");
  41.     }
  42.  
  43.     // }}}
  44.     // {{{ functions
  45.  
  46.     /**
  47.      * 初期設定を行う.
  48.      *
  49.      * @access protected
  50.      * @return void 
  51.      */
  52.     function init({
  53.         $this->requireInitialConfig();
  54.         $this->defineDSN();
  55.         $this->setErrorReporting();
  56.         $this->defineConstants();
  57.         $this->mbstringInit();
  58.         $this->createCacheDir();
  59.     }
  60.  
  61.     /**
  62.      * 初期設定ファイルを読み込む.
  63.      *
  64.      * @access protected
  65.      * @return void 
  66.      */
  67.     function requireInitialConfig({
  68.  
  69.         require_once(realpath(dirname__FILE__)) ."/../install.php");
  70.     }
  71.  
  72.     /**
  73.      * DSN を定義する.
  74.      *
  75.      * @access protected
  76.      * @return void 
  77.      */
  78.     function defineDSN({
  79.         if(defined('DB_TYPE'&& defined('DB_USER'&& defined('DB_PASSWORD')
  80.            && defined('DB_SERVER'&& defined('DB_PORT'&& defined('DB_NAME')) {
  81.             /** サイト用DB */
  82.             define ("DEFAULT_DSN",
  83.                     DB_TYPE "://" DB_USER ":" DB_PASSWORD "@"
  84.                     . DB_SERVER ":" .DB_PORT "/" DB_NAME);
  85.         else {
  86.             define("DEFAULT_DSN""pgsql://nobody:password@localhost:5432/eccubedb");
  87.         }
  88.     }
  89.  
  90.  
  91.     /**
  92.      * エラーレベル設定を行う.
  93.      *
  94.      * ・推奨値
  95.      *   開発時 - E_ALL
  96.      *   運用時 - E_ALL & ~E_NOTICE
  97.      *
  98.      * @access protected
  99.      * @return void 
  100.      */
  101.     function setErrorReporting({
  102.         error_reporting(E_ALL ~E_NOTICE);
  103.         // PHP 5.3.0対応
  104.         if (error_reporting(6143{
  105.             error_reporting(E_ALL ~E_NOTICE ~E_DEPRECATED);
  106.         }
  107.     }
  108.  
  109.     /**
  110.      * マルチバイト文字列設定を行う.
  111.      *
  112.      * TODO SJIS-win や, eucJP-win への対応
  113.      *
  114.      * @access protected
  115.      * @return void 
  116.      */
  117.     function mbstringInit({
  118.         ini_set("mbstring.http_input"CHAR_CODE);
  119.         ini_set("mbstring.http_output"CHAR_CODE);
  120.         ini_set("auto_detect_line_endings"1);
  121.         ini_set("default_charset"CHAR_CODE);
  122.         ini_set("mbstring.internal_encoding"CHAR_CODE);
  123.         ini_set("mbstring.detect_order""auto");
  124.         ini_set("mbstring.substitute_character""none");
  125.         //ロケールを明示的に設定
  126.         setlocale(LC_ALLLOCALE);
  127.     }
  128.  
  129.     /**
  130.      * 定数を設定する.
  131.      *
  132.      * mtb_constants.php を読み込んで定数を設定する.
  133.      * キャッシュディレクトリに存在しない場合は, 初期データからコピーする.
  134.      *
  135.      * @access protected
  136.      * @return void 
  137.      */
  138.     function defineConstants({
  139.  
  140.         $errorMessage "<div style='color: #F00; font-weight: bold; "
  141.             . "background-color: #FEB; text-align: center'>"
  142.             . CACHE_PATH
  143.             . " にユーザ書込み権限(777等)を付与して下さい。</div>";
  144.  
  145.         // 定数を設定
  146.         if (is_file(CACHE_PATH "mtb_constants.php")) {
  147.             require_once(CACHE_PATH "mtb_constants.php");
  148.  
  149.             // キャッシュが無ければ, 初期データからコピー
  150.         elseif (is_file(CACHE_PATH "../mtb_constants_init.php")) {
  151.  
  152.             $mtb_constants file_get_contents(CACHE_PATH "../mtb_constants_init.php");
  153.             if (is_writable(CACHE_PATH)) {
  154.                 $handle fopen(CACHE_PATH "mtb_constants.php""w");
  155.                 if (!$handle{
  156.                     die($errorMessage);
  157.                 }
  158.                 if (fwrite($handle$mtb_constants=== false{
  159.                     die($errorMessage);
  160.                 }
  161.                 fclose($handle);
  162.  
  163.                 require_once(CACHE_PATH "mtb_constants.php");
  164.             else {
  165.                 die($errorMessage);
  166.             }
  167.         else {
  168.             die(CACHE_PATH "../mtb_constants_init.php が存在しません");
  169.         }
  170.     }
  171.  
  172.     /**
  173.      * 各種キャッシュディレクトリを生成する.
  174.      *
  175.      * Smarty キャッシュディレクトリを生成する.
  176.      *
  177.      * @access protected
  178.      * @return void 
  179.      */
  180.     function createCacheDir({
  181.         if (defined("HTML_PATH")) {
  182.             umask(0);
  183.             if (!file_exists(COMPILE_DIR)) {
  184.                 mkdir(COMPILE_DIR);
  185.             }
  186.  
  187.             if (!file_exists(MOBILE_COMPILE_DIR)) {
  188.                 mkdir(MOBILE_COMPILE_DIR);
  189.             }
  190.  
  191.             if (!file_exists(COMPILE_ADMIN_DIR)) {
  192.                 mkdir(COMPILE_ADMIN_DIR);
  193.             }
  194.  
  195.             if (!file_exists(COMPILE_FTP_DIR)) {
  196.                 mkdir(COMPILE_FTP_DIR);
  197.             }
  198.         }
  199.     }
  200. }
  201. ?>

Documentation generated on Fri, 24 Feb 2012 14:00:17 +0900 by Seasoft